﻿
@{
    ViewBag.Title = "上传Img";
}

<h2>上传Img</h2>

<form action="/Home/UpLoadFiles" method="post" enctype="multipart/form-data">
    <input type="file" id="files" name="files" value="" />
    <input type="button" id="btnOK" name="btnOK" value="上传" onclick="onUpLoad()" />
    <br />
    <img src="" alt="图片" id="Imgs" hidden="hidden" />
</form>

<script>

    ///上传
    function onUpLoad() {
        var formData = new FormData();
        formData.append("MyImg", document.getElementById("files").files[0]);
        $.ajax({
            type: "POST",
            url: "/Home/UpLoadFiles",
            data: formData,
            async: false,
            dataType: "json",
            contentType: false,
            processData: false,
            success: function (data) {
                if (data.status == "true") {

                }
            }
        });
    }

</script>